/*******************************************************************************
AVR8sa1Main.c

===============================================================================
Copyright (c) 2010, Centeye, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of Centeye, Inc. nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL CENTEYE, INC. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===============================================================================

AVR8 standalone sensor main function

This is the top level code. In the future we may merge this with AVRsa1os1.

This code should NOT need to be changed to make minor edits to the application
firmware, if using the current simplified communications handler and the
I2C/TWI interface alone.

Origin:
Adapted from AVR8 by Travis Young.

Change Log:
2010 May 21, Friday, birth
2010 August 6, Friday, documentation

******************************************************************************/


#include "AVR8sa1os101.h"
#include "ApplicationPrototype.h"
#include <avr/eeprom.h>

// The include file below will depend on the vision chip being used with this
// sensor board.
#include "F64PlusInterface.h"
//#include "FireflySmallInterface.h"

//void main(void) __attribute__((noreturn));
int main(void); // Just to get rid of the warning in AVR-GCC, makes no difference

int main(void)
{

	// Initialize the AVR and it's peripherals. This includes preparing the
	// I2C/TWI interface and setting port directions, for example.
	atmel_init(); // function found in AVR8sa1os1.c

	// Initialize the basic operating system for this sensor including comms.
	os_init(); // function found in AVR8sa1os1.c

	// Initialize the vision chip. This function may be found in the chip
	// interface library for example F64PlusInterface.c
	VC_init();

	// Initialize the variables for the algorithm firmware application. This 
	// function may be found in the application firmware source code. This is
	// one of the base functions that may be edited by a developer.
	Application_Init();

	// Now we execute the main loop of the application program. The contents of 
	// this function is also modified for each specific application. This is
	// therefore the other base function that may be edited by a developer.
	// This function is also found in the application source code.
	while(1) 
		Application_MainLoop();
}
